/**
 * @description:zh-CN 属性强化提升计算
 * @param {Object} elementIntensify - 属性强化
 * @param {object} resist - 怪物抗性
 * @returns {number} 1 + (属性强化 - 怪物抗性) / 2000 * 9
 */
export const elementIntensify = (unit, monster) => {
    let elementIntensify = unit.attr.elementIntensify;
    let monsterResist = monster.resist;

    return 1 + (elementIntensify - monsterResist) / 2000 * 9
}


export const intellectCount = (wally, itemInt) => {
    let wallyInt = wally.attr.intellect
    let wallyIntEnhance = wally.attr.intellectEnhance

    return (wallyInt + itemInt) * (1 + wallyIntEnhance) / 250 + 1
}

/**
 * 
 * 
 * @param {Object} unit 
 * @param {Object} item 
 * @returns {number}
 */
const attackCount = (unit, item) => {
    let weapon = unit.attr.attack.basis + unit.attr.attack.other;
    let itemAtk = item.attr.attack.basis;
    let enhanceAtk = unit.attr.attackEnhance;

    weapon = ($scope.have.unit) ? 0 : weapon;
    itemAtk = ($scope.have.item) ? 0 : itemAtk;

    return (unit + item + other) * (1 + enhanceAtk)
}

/**
 *
 * @param unitLvevl - 玩家等级
 * @param defensePiercingDmg - 无视防御攻击
 * @param monsterIgnoreRatio - 怪物对无视防御攻击的抵抗率
 * @returns {number}
 */
export const monsterDecrementCount = (unit, monster) => {
    let unitLvevl = unit.level;
    let defensePiercingDmg = unit.attr.defensePiercingDamage;
    let monsterIgnoreRatio = monster.ignoreRatio

    return (1 - monster.getDecrement(unitLvevl)) + defensePiercingDmg * monster.monsterIgnoreRatio
}


/**
 * 
 * 
 * @param {Object} unit 
 * @param {Object} item 
 * @returns 
 */
export const criticalCount = (unit, item) => {
    let critical = unit.attr.critical + item.attr.critical;
    let criticalDmg = unit.attr.criticalDamage + item.attr.criticalDamage;
    let addCriticalDmg = unit.attr.additionalCriticalDamage + item.attr.additionalCriticalDamage;

    critical = critical > 1 ? 1 : critical;

    return (1 + (1.5 * (1 + criticalDmg + addCriticalDmg) - 1) * critical)
}


export const bonusDamageCount = (unit, item) => 1 + unit.attr.bonusDamage + item.attr.bonusDamage;

export const attackDamage = (unit, item) => 1 + (unit.attr.attackDamage + item.attr.attackDamage) + (unit.attr.attackDamage + item.attr.attackDamage) + hasMedicine();
